const express = require('express');
const cors = require('cors');
const app = express();
const db = require('./db/db');

// 中间件
app.use(cors());
app.use(express.json());

// 路由
const taskRoutes = require('./routes/taskRoutes');
app.use('/api/tasks', taskRoutes);

// 数据库初始化
db.serialize(() => {
    db.run('PRAGMA foreign_keys = ON;');
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Server running on port ${PORT}`);
});
